<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <title>新增xx设备弹框</title>
    <meta name="renderer" content="webkit" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <meta
      name="viewport"
      content="width=device-width, initial-scale=1, maximum-scale=1"
    />
    <link
      rel="stylesheet"
      href="../../lib/layui-v2.5.5/css/layui.css"
      media="all"
    />
    <link rel="stylesheet" href="../../css/public.css" media="all" />
  </head>
  <style>
    td .layui-form-select {
      margin-top: -10px;
      margin-left: -15px;
      margin-right: -15px;
    }
  </style>
  <body>
    <div class="layuimini-container">
      <div class="layuimini-main">
        <div style="margin: 10px 10px 10px 10px">
          <form class="layui-form layui-form-pane" action="">
            <div class="layui-form-item">
              <div class="layui-inline" style="margin-left: 5%">
                <label class="layui-form-label">巡检时间</label>
                <div class="layui-input-inline">
                  <input
                    type="text"
                    name="time_xun"
                    autocomplete="off"
                    disabled
                    class="layui-input"
                  />
                </div>
              </div>
              <div class="layui-inline" style="margin-left: 30%">
                <label class="layui-form-label">巡检人员</label>
                <div class="layui-input-inline">
                  <input
                    type="text"
                    name="people"
                    placeholder="巡检人员名称"
                    autocomplete="off"
                    class="layui-input"
                  />
                </div>
              </div>
            </div>
          </form>
        </div>
        <div id="Myloading">
          <img
            src="../../lib/layui-v2.5.5/css/modules/layer/default/loading-01.gif"
            alt=""
          />
        </div>

        <script type="text/html" id="toolbarDemo">
          <div class="layui-btn-container">
            <button class="layui-btn layui-btn-sm data-add-btn" lay-event="add">
              提交表格
            </button>
          </div>
        </script>

        <table
          class="layui-hide"
          id="currentTableId"
          lay-filter="currentTableFilter"
        ></table>

        <script type="text/html" id="currentTableBar">
          <a lay-event="edit"><img src="../../images/icon-qxt.png" alt="" /></a>
        </script>

        <script type="text/html" id="remark_temp">
          <input
            type="text"
            onkeyup="value=value.replace(/[^\d]/g,'')"
            lay-vertype="tips"
            id="k_{{d.LAY_TABLE_INDEX}}"
            placeholder="{{d.placeholder}}"
            autocomplete="off"
            class="layui-input"
            name="remark"
            lay-event="editRemark"
          />
        </script>
      </div>
    </div>
    <script src="../../lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
    <script src="../../js/lay-config.js?v=1.0.4" charset="utf-8"></script>
    <script>
      layui.use(["form", "table", "miniTab"], function () {
        // 2020-03-25 HF 保存token
        var token = sessionStorage.getItem("newtoken");
        var x_j = {};
        var device_code = null;

        var $ = layui.jquery,
          form = layui.form,
          miniTab = layui.miniTab,
          table = layui.table;
        miniTab.listen();

        let nowtime = new Date();
        var s1 = GMTToStr(nowtime);
        $("input[name='time_xun']").val(s1);

        var data = [
          {
            name: "油箱",
            que: "油温是否正常？",
            field: "1",
            flag: "oilTempStatus",
            placeholder: "填0或1，其中1=正常，0=异常",
          },
          {
            name: "油箱",
            que: "储油柜油柜是否正常？",
            field: "2",
            flag: "oilCabinetStatus",
            placeholder: "填0或1，其中1=正常，0=异常",
          },
          {
            name: "油箱",
            que: "油位和油温对应是否正常？",
            field: "3",
            flag: "oilLevelStatus",
            placeholder: "填0或1，其中1=正常，0=异常",
          },
          {
            name: "油箱",
            que: "油箱密封是否正常？",
            field: "4",
            flag: "oilTankStatus",
            placeholder: "填0或1，其中1=正常，0=异常",
          },
          {
            name: "油箱",
            que: "吸湿器外观颜色",
            field: "5",
            flag: "humidifierStatus",
            placeholder: "0=红色，1=蓝色，2=白色，3=黑色",
          },
          {
            name: "油箱",
            que: "变压器音响是否正常？",
            field: "6",
            flag: "transSoundStatus",
            placeholder: "填0或1，其中1=正常，0=异常",
          },
          {
            name: "套管",
            que: "套管油位是否正常？",
            field: "7",
            flag: "bushingOilLevelStatus",
            placeholder: "填0或1，其中1=正常，0=异常",
          },
          {
            name: "套管",
            que: "套管外观有无破损裂纹？",
            field: "8",
            flag: "bushingSurfaceStatus",
            placeholder: "填0或1，其中1=无 ，0=有",
          },
          {
            name: "套管",
            que: "套管是否存在油污？",
            field: "9",
            flag: "bushingGreasyDirtStatus",
            placeholder: "填0或1，其中1=否，0=是",
          },
          {
            name: "套管",
            que: "套管是否存在放电痕迹？",
            field: "10",
            flag: "bushingPDStatus",
            placeholder: "填0或1，其中1=否，0=是",
          },
          {
            name: "套管",
            que: "套管是否存在其他异常现象？",
            field: "11",
            flag: "bushingDamageStatus",
            placeholder: "填0或1，其中1=否，0=是",
          },
          {
            name: "非电量保护系统",
            que: "压力释放阀是否正常？",
            field: "12",
            flag: "pressureReliefValveStatus",
            placeholder: "填0或1，其中1=正常，0=异常",
          },
          {
            name: "非电量保护系统",
            que: "安全气道是否正常？",
            field: "13",
            flag: "safeAirwaysStatus",
            placeholder: "填0或1，其中1=正常，0=异常",
          },
          {
            name: "非电量保护系统",
            que: "防爆膜是否正常？",
            field: "14",
            flag: "burstingDiaphragmStatus",
            placeholder: "填0或1，其中1=正常，0=异常",
          },
          {
            name: "非电量保护系统",
            que: "气体继电器内有无气体？",
            field: "15",
            flag: "gasRelayStatus",
            placeholder: "填0或1，其中1=无，0=有",
          },
          {
            name: "非电量保护系统",
            que: "引线接头是否发热？",
            field: "16",
            flag: "leadConnectorStatus",
            placeholder: "填0或1，其中1=否，0=是",
          },
          {
            name: "非电量保护系统",
            que: "电缆是否发热？",
            field: "17",
            flag: "cableStatus",
            placeholder: "填0或1，其中1=否，0=是",
          },
          {
            name: "非电量保护系统",
            que: "母线是否发热？",
            field: "18",
            flag: "busStatus",
            placeholder: "填0或1，其中1=否，0=是",
          },
          {
            name: "非电量保护系统",
            que: "控制箱是否受潮？",
            field: "19",
            flag: "controlCabinetStatus",
            placeholder: "填0或1，其中1=否，0=是",
          },
          {
            name: "非电量保护系统",
            que: "端子箱是否受潮？",
            field: "20",
            flag: "terminalCabinetStatus",
            placeholder: "填0或1，其中1=否，0=是",
          },
          {
            name: "分接开关",
            que: "分接开关的分接位置是否正常？",
            field: "21",
            flag: "tapPositionStatus",
            placeholder: "填0或1，其中1=正常，0=异常",
          },
          {
            name: "分接开关",
            que: "分接开关电源指示是否正常？",
            field: "22",
            flag: "tapPowerStatus",
            placeholder: "填0或1，其中1=正常，0=异常",
          },
          {
            name: "冷却系统",
            que: "风扇运转是否正常？",
            field: "23",
            flag: "fanStatus",
            placeholder: "填0或1，其中1=正常，0=异常",
          },
          {
            name: "冷却系统",
            que: "油泵运转是否正常？",
            field: "24",
            flag: "oilPumpStatus",
            placeholder: "填0或1，其中1=正常，0=异常",
          },
          {
            name: "冷却系统",
            que: "水泵运转是否正常？",
            field: "25",
            flag: "waterPumpStatus",
            placeholder: "填0或1，其中1=正常，0=异常",
          },
          //    {name:"冷却系统",
          //    	   que:"气体继电器内有无气体？",
          //    	   field:"26",
          //             flag:"gasRelayStatus",
          //             placeholder:'填0或1，其中1=无， 0=有'
          //    },
          {
            name: "冷却系统",
            que: "油流继电器是否正常?",
            field: "27",
            flag: "oilRelayStatus",
            placeholder: "填0或1，其中1=正常，0=异常",
          },
          {
            name: "冷却系统",
            que: "各冷却器手感温度比较？",
            field: "28",
            flag: "fanTempStatus",
            placeholder: "填0或1，其中1=正常，0=异常",
          },
          {
            name: "变压器",
            que: "运行状态",
            field: "1",
            flag: "runningStatus",
            placeholder: "填写0或1，其中1=正常，0=异常",
          },
          {
            name: "变压器",
            que: "油温一温度",
            field: "1",
            flag: "oilFirstTemperature",
            placeholder: "≤75℃",
          },
          {
            name: "变压器",
            que: "油温二温度",
            field: "1",
            flag: "oilSecondTemperature",
            placeholder: "≤75℃",
          },
          {
            name: "变压器",
            que: "绕组温度",
            field: "1",
            flag: "windingTemperature",
            placeholder: "≤105℃",
          },
          {
            name: "变压器",
            que: "总烃检测",
            field: "1",
            flag: "h2",
            placeholder: "≤150ppm",
          },
          {
            name: "变压器",
            que: "微水检测",
            field: "1",
            flag: "microWater",
            placeholder: "≤15ppm",
          },
          {
            name: "变压器",
            que: "储油柜油温表对应曲线油位",
            field: "1",
            flag: "oilMeterLevel",
            placeholder: "≤10",
          },
          {
            name: "变压器",
            que: "硅胶受潮变色",
            field: "1",
            flag: "silicaGelTidalDiscoloration",
            placeholder: "填写0或1，其中1=小于1/2，0=大于1/2",
          },
        ];

        table.render({
          elem: "#currentTableId",
          toolbar: "#toolbarDemo",
          data: data,
          defaultToolbar: [
            "filter",
            "exports",
            "print",
            {
              title: "提示",
              layEvent: "LAYTABLE_TIPS",
              icon: "layui-icon-tips",
            },
          ],

          cols: [
            [
              //复选框 {type: "checkbox", width: 50, fixed: "left"},
              { type: "numbers", width: 120, title: "序号", align: "center" },
              { field: "name", minWidth: 110, title: "类型", align: "center" },
              { field: "que", minWidth: 110, title: "状况", align: "center" },
              {
                field: "remark",
                title: "数值",
                minWidth: 110,
                align: "center",
                templet: "#remark_temp",
              },
              {
                title: "操作",
                width: 250,
                templet: "#currentTableBar",
                fixed: "right",
                align: "center",
              },
            ],
          ],
          limits: [10, 15, 20, 25, 50, 100],
          limit: 105,
          page: false,
          done: function (res) {
            if (res.code == -1) {
              window.location = "../login-1.html";
            }
            // 表格渲染完成回调
            $("#Myloading").remove();
          },
        });
        // 监听搜索操作
        form.on("submit(data-search-btn)", function (data) {
          // var result = JSON.stringify(data.field.username);
          // console.log(data);

          // layer.alert(result, {
          //     title: '最终的搜索信息'
          // });

          //执行搜索重载
          table.reload(
            "currentTableId",
            {
              //     page: {
              //         curr: 1
              //     }
              //     , where: {
              //         'text': result
              //     }
            },
            "data"
          );

          return false;
        });

        /**
         * toolbar监听事件
         */
        table.on("toolbar(currentTableFilter)", function (obj) {
          console.log(obj, "xun_jian");
          device_code = sessionStorage.getItem("HsaveOverHaul_code");
          x_j.patrolDate = $("input[name='time_xun']").val();
          if ($("input[name='people']").val() == "") {
            x_j.patrolStaff = "operate";
          } else {
            x_j.patrolStaff = $("input[name='people']").val();
          }
          x_j.deviceCode = device_code;
          if ($("#k_0").val() == "" || $("#k_0").val() == "0") {
            x_j.oilTempStatus = "0";
          } else {
            x_j.oilTempStatus = "1";
          }
          if ($("#k_1").val() == "" || $("#k_1").val() == "0") {
            x_j.oilCabinetStatus = "0";
          } else {
            x_j.oilCabinetStatus = "1";
          }
          if ($("#k_2").val() == "" || $("#k_2").val() == "0") {
            x_j.oilLevelStatus = "0";
          } else {
            x_j.oilLevelStatus = "1";
          }
          if ($("#k_3").val() == "" || $("#k_3").val() == "0") {
            x_j.oilTankStatus = "0";
          } else {
            x_j.oilTankStatus = "1";
          }
          if ($("#k_4").val() == "" || $("#k_4").val() == "0") {
            x_j.humidifierStatus = "0";
          } else {
            x_j.humidifierStatus = $("#k_4").val();
          }
          if ($("#k_5").val() == "" || $("#k_5").val() == "0") {
            x_j.transSoundStatus = "0";
          } else {
            x_j.transSoundStatus = "1";
          }
          if ($("#k_6").val() == "" || $("#k_6").val() == "0") {
            x_j.bushingOilLevelStatus = "0";
          } else {
            x_j.bushingOilLevelStatus = "1";
          }
          if ($("#k_7").val() == "" || $("#k_7").val() == "0") {
            x_j.bushingSurfaceStatus = "0";
          } else {
            x_j.bushingSurfaceStatus = "1";
          }
          if ($("#k_8").val() == "" || $("#k_8").val() == "0") {
            x_j.bushingGreasyDirtStatus = "0";
          } else {
            x_j.bushingGreasyDirtStatus = "1";
          }
          if ($("#k_9").val() == "" || $("#k_9").val() == "0") {
            x_j.bushingPDStatus = "0";
          } else {
            x_j.bushingPDStatus = "1";
          }
          if ($("#k_10").val() == "" || $("#k_10").val() == "0") {
            x_j.bushingDamageStatus = "0";
          } else {
            x_j.bushingDamageStatus = "1";
          }
          if ($("#k_11").val() == "" || $("#k_11").val() == "0") {
            x_j.pressureReliefValveStatus = "0";
          } else {
            x_j.pressureReliefValveStatus = "1";
          }
          if ($("#k_12").val() == "" || $("#k_12").val() == "0") {
            x_j.safeAirwaysStatus = "0";
          } else {
            x_j.safeAirwaysStatus = "1";
          }
          if ($("#k_13").val() == "" || $("#k_13").val() == "0") {
            x_j.burstingDiaphragmStatus = "0";
          } else {
            x_j.burstingDiaphragmStatus = "1";
          }
          if ($("#k_14").val() == "" || $("#k_14").val() == "0") {
            x_j.gasRelayStatus = "0";
          } else {
            x_j.gasRelayStatus = "1";
          }
          if ($("#k_15").val() == "" || $("#k_15").val() == "0") {
            x_j.leadConnectorStatus = "0";
          } else {
            x_j.leadConnectorStatus = "1";
          }
          if ($("#k_16").val() == "" || $("#k_16").val() == "0") {
            x_j.cableStatus = "0";
          } else {
            x_j.cableStatus = "1";
          }
          if ($("#k_17").val() == "" || $("#k_17").val() == "0") {
            x_j.busStatus = "0";
          } else {
            x_j.busStatus = "1";
          }
          if ($("#k_18").val() == "" || $("#k_18").val() == "0") {
            x_j.controlCabinetStatus = "0";
          } else {
            x_j.controlCabinetStatus = "1";
          }
          if ($("#k_19").val() == "" || $("#k_19").val() == "0") {
            x_j.terminalCabinetStatus = "0";
          } else {
            x_j.terminalCabinetStatus = "1";
          }
          if ($("#k_20").val() == "" || $("#k_20").val() == "0") {
            x_j.tapPositionStatus = "0";
          } else {
            x_j.tapPositionStatus = "1";
          }
          if ($("#k_21").val() == "" || $("#k_21").val() == "0") {
            x_j.tapPowerStatus = "0";
          } else {
            x_j.tapPowerStatus = "1";
          }
          if ($("#k_22").val() == "" || $("#k_22").val() == "0") {
            x_j.fanStatus = "0";
          } else {
            x_j.fanStatus = "1";
          }
          if ($("#k_23").val() == "" || $("#k_23").val() == "0") {
            x_j.oilPumpStatus = "0";
          } else {
            x_j.oilPumpStatus = "1";
          }
          if ($("#k_24").val() == "" || $("#k_24").val() == "0") {
            x_j.waterPumpStatus = "0";
          } else {
            x_j.waterPumpStatus = "1";
          }
          // if(  $('#k_25').val() == '' ||  $('#k_25').val() == '0'){x_j.gasRelayStatus = "0"}else{x_j.gasRelayStatus = "1" }
          if ($("#k_25").val() == "" || $("#k_25").val() == "0") {
            x_j.oilRelayStatus = "0";
          } else {
            x_j.oilRelayStatus = "1";
          }
          if ($("#k_26").val() == "" || $("#k_26").val() == "0") {
            x_j.fanTempStatus = "0";
          } else {
            x_j.fanTempStatus = "1";
          }
          if ($("#k_27").val() == "" || $("#k_27").val() == "0") {
            x_j.runningStatus = "0";
          } else {
            x_j.runningStatus = "1";
          }
          if ($("#k_28").val() == "" || $("#k_28").val() == "0") {
            x_j.oilFirstTemperature = "0";
          } else {
            x_j.oilFirstTemperature = $("#k_29").val();
          }
          if ($("#k_29").val() == "" || $("#k_29").val() == "0") {
            x_j.oilSecondTemperature = "0";
          } else {
            x_j.oilSecondTemperature = $("#k_30").val();
          }
          if ($("#k_30").val() == "" || $("#k_30").val() == "0") {
            x_j.windingTemperature = "0";
          } else {
            x_j.windingTemperature = $("#k_31").val();
          }
          if ($("#k_31").val() == "" || $("#k_31").val() == "0") {
            x_j.h2 = "0";
          } else {
            x_j.h2 = $("#k_32").val();
          }
          if ($("#k_32").val() == "" || $("#k_32").val() == "0") {
            x_j.microWater = "0";
          } else {
            x_j.microWater = $("#k_33").val();
          }
          if ($("#k_33").val() == "" || $("#k_33").val() == "0") {
            x_j.oilMeterLevel = "0";
          } else {
            x_j.oilMeterLevel = $("#k_34").val();
          }
          if ($("#k_34").val() == "" || $("#k_34").val() == "0") {
            x_j.silicaGelTidalDiscoloration = "0";
          } else {
            x_j.silicaGelTidalDiscoloration = "1";
          }

          layer.confirm(
            "确定增加该数据吗？",
            {
              btn: ["确定", "取消"], //按钮
            },
            function () {
              addXun_jian(x_j);
            }
          );
        });

        //监听表格复选框选择
        table.on("checkbox(currentTableFilter)", function (obj) {});

        // 获取列表data
        table.on("tool(currentTableFilter)", function (obj) {
          if (obj.event === "edit") {
            sessionStorage.setItem("HsaveOverHaul_flag", obj.data.flag);
            sessionStorage.setItem("HsaveOverHaul_ms", obj.data.que);

            var index = layer.open({
              title: "新增配置",
              type: 2,
              shade: 0.2,
              maxmin: true,
              shadeClose: true,
              area: ["80%", "80%"],
              content: "./line_x/line_xj.html",
              // content: ['./line_x/line_xj.html','no'] //滚动条
            });
          }
        });
        // 新增接口
        function addXun_jian(x_j) {
          $.ajax({
            url: "/oms-web/patrols/transformer/authority?token=" + token,
            dataType: "json",
            type: "post",
            data: JSON.stringify(x_j),
            contentType: "application/json",
            success: function (data) {
              if (data.code == -1) {
                window.location = "../login-1.html";
              }
              if (data.code === 0) {
                layer.msg(data.msg, { icon: 1, time: 1500 }, function () {
                  parent.layer.close(iframeIndex);
                  window.parent.location.reload(); //修改成功后刷新父界面
                });
              } else {
                layer.msg(data.msg, { icon: 1, time: 1000 });
              }
            },
            error: function () {
              layer.msg("数据请求错误！");
              layer.close(index);
            },
          });
        }
        var iframeIndex = parent.layer.getFrameIndex(window.name);
      });

      function GMTToStr(time) {
        function add0(m) {
          return m < 10 ? "0" + m : m;
        } //避免少0
        var time = new Date(time);
        var year = time.getFullYear();
        var month = time.getMonth() + 1;
        var date = time.getDate();
        var hours = time.getHours();
        var minutes = time.getMinutes();
        var seconds = time.getSeconds();
        return (
          year +
          "-" +
          add0(month) +
          "-" +
          add0(date) +
          " " +
          add0(hours) +
          ":" +
          add0(minutes) +
          ":" +
          add0(seconds)
        );
      }
    </script>
  </body>
</html>
